package aad.storyboard.controller;

import android.util.Log;

public class StoppedState implements IState{
	
	
        //define a instance to hold reference of Context Object (MP3Player)
        private AudioPlayer audioPlayer;
        
        //constructor should accept the context reference instance
        public StoppedState(AudioPlayer a){
            System.out.println("=== Stopped State ===");
            audioPlayer = a;              	   
        }
        
        //implementation of IState methods
        @Override
		public void playAudio()
        {
            System.out.println("PLAYING STATE IN STOPPED STATE: ---");
            try {    
            	
                audioPlayer.initializeMediaPlayer();
            	audioPlayer.getPlayer().start();            
               
            } catch (Exception e) {
                Log.e("", "error: " + e.getMessage(), e);}
            
            audioPlayer.setNewState(audioPlayer.getPlayingState());
        }
        
        @Override
		public void pauseAudio()
        {
        	System.out.println("Stopped Track cannot be paused");
        	
        }
        
        @Override
		public void stopAudio()
        {
        	System.out.println("Player is already Stopped");
        }

		@Override
		public void seekToPosition(int position) {
			System.out.println("SEKING IN STOPPED STATE: ---");
			audioPlayer.initializeMediaPlayer();		
			audioPlayer.getPlayer().start();
			audioPlayer.getPlayer().seekTo(position);
			audioPlayer.setNewState(audioPlayer.getPlayingState());
		}
    

}
